/**
 * Xinfei.com Inc.
 * Copyright (c) 2004-2024 All Rights Reserved.
 */
package com.xinfei.techplayprod.biz.mq;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 消息发送测试
 *
 * @author Chengsheng.Li
 * @version $ MqTest, v 0.1 2024/2/20 11:18 Chengsheng.Li Exp $
 */
@Component
public class MqTest {

    @Value("${mq.test:true}")
    private boolean mqTest;
    @PostConstruct
    public void init() {
        new Thread(() -> {
            int count = 0;
            while (true) {
                try {
                    if(mqTest){
                      MqSendUtil.syncSend(MqConstant.TEST_TOPIC, count++);
                    }
                    Thread.sleep(10000);
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}